module.exports = function ($scope, $stateParams, $state, $resource, $modal, toaster) {
	$scope.myKeyup = function (e) {
		//IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
		var keycode = window.event ? e.keyCode : e.which;
		if (keycode == 13) {
			$scope.loadlist();
		}
	};
	$scope.currentPage = 1;		//当前页码
	$scope.itemsPerPage = 10;	//每页显示几条
	$scope.pageInfo = {};
	$scope.pageInfo.type = $stateParams.type;
	//卡列表
	$scope.loadlist = function () {
		var para = {
			'pageNo': $scope.currentPage,
			'pageSize': $scope.itemsPerPage
		}
		angular.extend(para, $scope.pageInfo);
		$resource('/api/as/ggc/bus/findBusSeatsList', {}, {}).save(para, function (res) {
			if (res.errcode === 0) {
				$scope.busList = res.data.results;
				$scope.totalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
	}

	$scope.loadlist();
	
	$scope.edit = function (bus) {
        var modalInstance = $modal.open({
            template: require('../views/tourBusInfo.html'),
            controller: 'tourBusInfo',
            size: 'lg',
            resolve: {
                bus: function () {
                    return bus;
                }
            }
        });
        modalInstance.result.then(function (result) {
            $scope.order_info = result;
        });
	}

	//房间信息
	$scope.setBusSeats = function () {
		var modalInstance = $modal.open({
			template: require('../views/tourSetBusSeats.html'),
			controller: 'tourSetBusSeats',
			size: 'lg',
			resolve: {
			}
		});
		//关闭模态框刷新页面
		modalInstance.result.then(function () {
			$scope.loadlist();
		});
	}

};